#ifndef __SPRITE_H__
#define __SPRITE_H__

#include "esEffectBase.h"

enum eShader
{
    eShader,
    eShaderNum,
};

enum eIndexVbo
{
    eIndexVbo,
    eIndexVboNum,
};

class Sprite : public esEffectBase {
protected:
	int _Index;								// Current sprite index
	int _Width;								// Sprite width
	int _Height;							// Sprite height
	int _Count;								// Number of sprites
	int _SpritePerRow;						// Number of sprites per row
    
    GLushort m_uiColumns;	// Number of mesh subdivisions along the x axis }
    GLushort m_uiRows;		// Number of mesh subdivisions along the y axis }
    
    PVRTVec3* m_av3Vertices;
    PVRTVec2* m_av2TexCoord;
    PVRTVec4* m_av4Color;
    PVRTVec3* m_av3Normals;
    GLushort m_uiNumVertices;  // For large, complex meshes where the vertex count exceeds the max range of u_short (65535),
    
    GLushort* m_auiIndices;
    GLushort m_uiStripLength;
    
    struct
    {
        GLuint uiId;
        GLuint uiMVPMatrixLoc;
    }
    m_ShaderProgram;
    
public: 
	Sprite(char *Path, int Width, int Height, int Count, int SpritePerRow);
    ~Sprite();

private:
    bool LoadShader(CPVRTString* pErrorStr);
    void CreateMesh();
    void CreateTriangleStrip();
    
public:
    void Render(int X, int Y);	// Render current sprite at location (X,Y) at the target surface
    static void GenTexture(char* filename, GLuint* texName);
    
    
	void Next();
	void Next1();
	void Next2();
	void Next3();
	void Next4();
	void Next5();
	void Next6();
	void Next7();
};

#endif